//
//  YXYZoomIdTableViewCell.m
//  Topit
//
//  Created by dllo on 15/12/8.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "YXYZoomIdTableViewCell.h"

@implementation YXYZoomIdTableViewCell

- (void)dealloc {
    [_idImage release];
    [_idName release];
    [_fnum release];
    [_heart release];
    [_zoomImageModel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.idImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _idImage.layer.cornerRadius = 15;
        _idImage.clipsToBounds = YES;
        [self addSubview:_idImage];
        [_idImage release];
        
        self.idName = [[UILabel alloc] initWithFrame:CGRectZero];
        _idName.font = [UIFont systemFontOfSize:10];
        [self addSubview:_idName];
        [_idName release];
        
        self.fnum = [[UILabel alloc] initWithFrame:CGRectZero];
        _fnum.textColor = [UIColor orangeColor];
        _fnum.font = [UIFont systemFontOfSize:12];
        [self addSubview:_fnum];
        [_fnum release];
        
        self.heart = [[UILabel alloc] initWithFrame:CGRectZero];
        self.heart.font = [UIFont systemFontOfSize:10];
        [self addSubview:_heart];
        [_heart release];
    }
    return self;
}

- (void)setZoomImageModel:(YXYZoomImageModel *)zoomImageModel {
    if (_zoomImageModel != zoomImageModel) {
        [_zoomImageModel release];
        _zoomImageModel = [_zoomImageModel retain];
    }
    NSString *num = [NSString stringWithFormat:@"%@", zoomImageModel.fav[@"num"]];
    
    [_idImage sd_setImageWithURL:[NSURL URLWithString:zoomImageModel.user[@"icon"][@"url"]]];
    [_idImage nightMode];
    
    _idName.text = zoomImageModel.user[@"name"];
    [_idName nightMode];
    
    _fnum.text = [num stringByAppendingString:@"人喜欢"];
    [_fnum nightMode];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _idImage.frame = CGRectMake(5, 5, 30, 30);
    _idName.frame = CGRectMake(_idImage.right + 5, _idImage.frame.origin.y + 2, 100, 10);
    _fnum.frame = CGRectMake(self.size.width - 80, _idImage.origin.y + 10, 60, 10);
    _heart.frame = CGRectMake(_fnum.right, _idImage.origin.y - 5, _idImage.width, _idImage.frame.size.height);
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
